import common from './common'

const paths = {
  saveConstructionUnit: 'projectBase/unit/save',
  deleteConstructionUnit: 'projectBase/unit/delete',
  getConstructionUnitByTYXYDM: 'projectBase/unit/getConstructionUnitByTYXYDM',
  deleteProjectBaseUnitRelation: 'projectBase/baseUnit/delete',
  getConstructionUnit: 'projectBase/unit/get',
  getDeclarantInfo: 'projectBase/declarant/get',
  saveDeclarant: 'projectBase/declarant/save',
  deleteDeclarant: 'projectBase/declarant/delete',
  getDeclarantByZJHM: 'projectBase/declarant/getDeclarantByZJHM',
  saveDesignUnit: 'projectBase/designUnit/save',
  deleteDesignUnit: 'projectBase/designUnit/delete',
  getDesignUnitInfo: 'projectBase/designUnit/get'
}

const unitManageService = {};

(function (service) {
  /**
   * 保存：建设单位基本信息
   * @param baseId
   * @param constructorUnit
   * @returns {Promise | Promise<unknown>}
   */
  service.saveConstructionUnit = (baseId, constructorUnit) => {
    return common.post(paths.saveConstructionUnit, { baseId }, constructorUnit)
  }
  /**
   * 获取：建设单位基本信息
   * @param unitId
   * @returns {Promise | Promise<unknown>}
   */
  service.getConstructionUnit = (unitId) => {
    return common.get(paths.getConstructionUnit, { unitId })
  }

  service.getConstructionUnitByTYXYDM = (tyxydm) => {
    return common.get(paths.getConstructionUnitByTYXYDM, { tyxydm })
  }
  /**
   * 删除：建设单位
   * @param unitId 建设单位Id
   * @returns {Promise | Promise<unknown>}
   */
  service.deleteConstructionUnit = (unitId) => {
    return common.get(paths.deleteConstructionUnit, { unitId })
  }

  /**
   * 获取：申报人基本信息
   * @param declarantId
   * @returns {Promise | Promise<unknown>}
   */
  service.getDeclarantInfo = (declarantId) => {
    return common.get(paths.getDeclarantInfo, { declarantId })
  }

  /**
   * 获取：根据证件号码获取申报人信息
   * @param zjhm
   * @returns {Promise | Promise<unknown>}
   */
  service.getDeclarantByZJHM = (zjhm) => {
    return common.get(paths.getDeclarantByZJHM, { zjhm })
  }

  /**
   * 保存申报人信息
   * @param declarant
   * @returns {Promise | Promise<unknown>}
   */
  service.saveDeclarant = (declarant) => {
    return common.post(paths.saveDeclarant, {}, declarant)
  }

  /**
   * 删除：申报人
   * @param declarantId 申报人Id
   * @returns {Promise | Promise<unknown>}
   */
  service.deleteDeclarant = (declarantId) => {
    return common.get(paths.deleteDeclarant, { declarantId })
  }

  /**
   * 保存设计单位
   * @param designUnit
   * @returns {Promise<unknown>}
   */
  service.saveDesignUnit = (designUnit) => {
    return common.post(paths.saveDesignUnit, {}, designUnit)
  }

  /**
   * 删除设计单位
   * @param designUnitId
   * @returns {Promise<unknown>}
   */
  service.deleteDesignUnit = (designUnitId) => {
    return common.get(paths.deleteDesignUnit, { designUnitId })
  }

  /**
   * 获取设计单位
   * @param designUnitId
   * @returns {Promise<unknown>}
   */
  service.getDesignUnitInfo = (designUnitId) => {
    return common.get(paths.getDesignUnitInfo, { designUnitId })
  }
})(unitManageService)

export default unitManageService
